package com.ktjiaoyu.crm.web;


import org.apache.shiro.authz.UnauthorizedException;
import org.springframework.web.bind.annotation.ControllerAdvice;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.servlet.ModelAndView;

import javax.servlet.http.HttpServletRequest;

/**
 * 全局异常处理
 */
@ControllerAdvice
public class GlobalExceptionHandler {

    @ExceptionHandler(UnauthorizedException.class)
    public ModelAndView unauthorizedExceptionHandler(HttpServletRequest request, UnauthorizedException e){
        ModelAndView mv = new ModelAndView("403");  //设置异常跳转路径
        mv.addObject("exception",e);    //将异常对象传递过去
        mv.addObject("url",request.getRequestURI());   //获得请求的路径

        return mv;
    }

}
